{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}
{block name="content"}
<script>
    function no_pic(obj) {
        obj.setAttribute("src", "/Public/Images/acp/nopicture.jpg");
    }
</script>

<div class="tablesWrap">
    <div class="tables-searchbox">
        <form method="post">
            <span class="tbs-txt">频道名称：</span>
            <input type="text" name="channel_name" value="{$channel_name}">

            <select name="sort" >
                <option value="">-所属栏目-</option>
                {foreach from=$channel_sort_list item=v}
                <option value="{$v.channel_sort_id}" {if $sort == $v.channel_sort_id}selected{/if}>{$v.channel_sort_name}</option>
                {/foreach}
            </select>
            <select name="type" >
                <option value="">-频道类型-</option>
                {foreach from=$channel_type item=v key=k}
                <option value="{$k}" {if $type == $k}selected{/if}>{$v}</option>
                {/foreach}
            </select>

            <button type="submit" class="btn"><i class="gicon-search"></i>搜索</button>
        </form>
    </div>
    <!-- end tables-searchbox -->
    <table class="wxtables">
        <colgroup>
            <!-- <col width="7%"> -->
            <col width="7%">
            <col width="7%">
            <col width="7%">
            <col width="7%">
            <col width="7%">
            <col width="7%">
            <col width="7%">
            <col width="15%">
        </colgroup>
        <thead>
        <tr>
            <!-- <td>选择</td> -->
            <td>频道名称</td>
            <td>图标</td>
            <td>所属栏目</td>
            <td>频道类型</td>
            <td>排序</td>
            <td>是否显示</td>
            <td>是否精选</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
        {foreach from=$channel_list  item=v }
        <tr>
            <!-- <td><input type="checkbox" class="checkbox" value="{$incubator.incubator_id}" name="checkIds[]"></td> -->
            <td>{$v.channel_name}</td>
            <td>
                <div class="gallery">
                    <div><a href="{$v.icon}"><img src="{$v.icon}" style="width:50px;display:block;"/></a></div>
                    <div class="clear"></div>
                </div>
            </td>
            <td>{$v.sort_name}</td>
            <td>{$v.type_name}</td>
            <td>{$v.serial}</td>
            <td>{if $v.isuse == 0}否{else}是{/if}</td>
            <td>{if $v.is_featured == 0}否{else}是{/if}</td>
            <td>
                {if $v.is_featured == 0}
                <a href="javascript:;" onclick="set_channel({$v.channel_id},1);" class="btn" title="精选">设置精选</a>
                {else}
                <a href="javascript:;" onclick="set_channel({$v.channel_id},0);" class="btn" title="取消">取消精选</a>
                {/if}
                <a href="/AcpChannel/add_edit_channel/channel_id/{$v.channel_id}" class="btn" title="修改"><i class="gicon-edit black"></i>编辑</a>
                <a href="javascript:;" onclick="del_channel({$v.channel_id});" class="btn" title="删除"><i class="gicon-trash black"></i>删除</a> 
            </td>
        </tr>
        {foreachelse}
        <tr><td colspan="10">没有找到任何记录</td></tr>
        {/foreach}
        </tbody>
    </table>
    <!-- end wxtables -->
    <div class="tables-btmctrl clearfix">
        <!-- <div class="fl">
            <a href="javascript:selall()" class="btn btn-blue">全选</a>
            <a href="javascript:clearall()" class="btn btn-blue">取消</a>
            <a href="javascript:;" class="btn btn-blue J_batch_store">下架</a>
            <a href="javascript:;" class="btn btn-blue" onclick="delIncubatorBatch()">删除</a>
        </div> -->
        <div class="fr">
            <div class="paginate">
                {$show}
            </div>
            <!-- end paginate -->
        </div>
    </div>
    <!-- end tables-btmctrl -->
</div>
<!-- end tablesWrap -->
{/block}

{block name="js"}
<script src="/Public/Plugins/My97DatePicker/WdatePicker.js?version={$version}"></script>
<script src="__JS__/front/jquery.showLoading.min.js?version={$version}"></script>
<script src="__JS__/clipboard.min.js"></script>
<link rel="stylesheet" href="__CSS__/front/showLoading.css?version={$version}">
{literal}
<script>
    function del_channel(channel_id)
    {
        var html = "确认删除这个频道吗?";
        $.jPops.custom({
            title:"删除频道",
            content:html,
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r)
            {
                if(r)
                {
                    $.post('/AcpChannel/del_channel',{'channel_id':channel_id},function(data) {
                        console.log(data)
                        if (data == 'success') {
                            alert('删除成功');
                            location.reload();
                        } else {
                            alert('删除失败，请稍后再试');
                        }
                    });
                }
                return true;
            }
        });
    }

    function set_channel(channel_id,type) {

        var html = "确认取消精选频道吗?";
        if(type == 1) {
             html = "确认设置精选频道吗?";
        }

        $.jPops.custom({
            title:html,
            content:'精选频道只能同时存在4个哦!',
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r)
            {
                if(r)
                {
                    $.post('/AcpChannel/is_featured',{'channel_id':channel_id,type:type},function(data) {
                        console.log(data)
                        if (data == 'success') {
                            alert('设置成功');
                            location.reload();
                        } else {
                            alert('设置失败，请稍后再试');
                        }
                    });
                }
                return true;
            }
        });
    }

</script>
{/literal}
{/block}
